home *** CD-ROM | disk | FTP | other *** search
- /*
- * Copyright 1992-1993, 1994, Silicon Graphics, Inc.
- * All Rights Reserved.
- *
- * This is UNPUBLISHED PROPRIETARY SOURCE CODE of Silicon Graphics, Inc.;
- * the contents of this file may not be disclosed to third parties, copied or
- * duplicated in any form, in whole or in part, without the prior written
- * permission of Silicon Graphics, Inc.
- *
- * RESTRICTED RIGHTS LEGEND:
- * Use, duplication or disclosure by the Government is subject to restrictions
- * as set forth in subdivision (c)(1)(ii) of the Rights in Technical Data
- * and Computer Software clause at DFARS 252.227-7013, and/or in similar or
- * successor clauses in the FAR, DOD or NASA FAR Supplement. Unpublished -
- * rights reserved under the Copyright Laws of the United States.
- */
- //////////////////////////////////////////////////////////////////////////////
- // Noise.h
- //////////////////////////////////////////////////////////////////////////////
-
- #ifndef NOISE_H
- #define NOISE_H
-
- #include <audio.h>
- #include <sys/types.h>
- #include <sys/prctl.h>
- #include <signal.h>
- #include <ulocks.h>
- #include "Defines.h"
- // #include <stdio.h>
- // #include <gl/gl.h>
- extern "C" {
- #include "sample.h"
- }
-
- struct Sound
- {
- float pitch;
- long length; // in samples
- };
-
- class Noise
- {
- public:
- Noise(const char *filename, int max_usec, Boolean cont = TRUE);
- ~Noise();
-
- void setContinuity(Boolean b) {
- _received_noise = FALSE;
- _continuous = b; };
-
- void play(float pitch, long usec); // pitch >= 0.0, 1.0 = original tone
- void play_now(float pitch, long usec); // not put in the queue
-
- // returns TRUE if this noise is playable (i.e. has a port)
- Boolean playable() {return (Boolean)_port;};
-
- protected:
-
- const char * _filename;
- sample * _s;
- ALport _port;
- ALconfig _config;
- long _max_samples; // max samples to play
-
- // FALSE if the process should sleep when the queue is empty
- // TRUE if the process should continue to play the last sound
- Boolean _continuous;
-
- // have we received anything yet?
- Boolean _received_noise;
-
- // fractional ptr into that array, start of next sound
- float _start;
-
- // array used to store the sound to be played
- short * _outsample;
-
- long sample_length(long usec);
-
- void makenoise(float last_pitch, float pitch, long samples);
-
- void audio_handler();
-
- usema_t * _noises_to_play; // number of noises in the queue to play
- int _in, _out; // queue head and tail
- Sound * _queue; // circular buffer of pitches to play
- };
-
- #endif
-